package main.java.indi.zyj.hot100;

public class _18_searchMatrix {

    public boolean searchMatrix(int[][] matrix, int target) {

        int row = matrix.length, col = matrix[0].length;
        int x = 0, y = col - 1;

        while (x < row && y >= 0) {
            if (target == matrix[x][y]) {
                return true;
            }
            if (matrix[x][y] > target) {
                y--;
            } else {
                x++;
            }
        }


        return false;

    }
}
